package com.walterlife.dp.FacadeDP;

import java.sql.Connection;

import org.apache.log4j.Logger;

public class HelperFacade {
   
    private static Logger logger = Logger.getLogger(HelperFacade.class);

    public void generateReport(DBTypes dbType, ReportTypes reportType, String tbName) {
        Connection conn = null;
        
        switch (dbType) {
            case MYSQL:
                conn = MySqlHelper.getMysqlDBConnection();
                MySqlHelper mysqlHelper = new MySqlHelper();
                switch (reportType) {
                    case PDF:
                        mysqlHelper.generateMySqlPDFReport(tbName, conn);
                        break;

                    case HTML:
                        mysqlHelper.generateMySqlHTMLReport(tbName, conn);
                        break;

                    default:
                        logger.error("HelperFacade generateReport reportType " + reportType + " not exist!!!");
                        break;
                } 
                break;

            case ORACLE:
                conn = OracleHelper.getOracleDBConnection();
                OracleHelper oracleHelper = new OracleHelper();
                switch (reportType) {
                    case PDF:
                        oracleHelper.generateOraclePDFReport(tbName, conn);
                        break;

                    case HTML:
                        oracleHelper.generateOracleHTMLReport(tbName, conn);
                        break;

                    default:
                        logger.error("HelperFacade generateReport reportType " + reportType + " not exist!!!");
                        break;
                }
                break;

            default:
                logger.error("HelperFacade generateReport dbType " + dbType + " not exist!!!");
                break;
        } 
    } 

    public static enum DBTypes {
        MYSQL,
        ORACLE;
    } 

    public static enum ReportTypes {
        PDF,
        HTML;
    } 
}
